package 剑指Offer;

public class Offer65_不用加减乘除做加法 {

    public int add(int a, int b) {
        while (b != 0) {// 当进位为 0 时跳出

            //一轮过后。a=tempSum  b=carraySum.即进位数字加上无需进位的数字
            int tempSum = a ^ b;
            int carrySum = (a & b) << 1;
            a = tempSum;
            b = carrySum;
        }
        return a;
    }
}
